package face.array;

import java.util.Arrays;

/**
 * @author spf
 * @date 2024/8/20
 * @time 21:33
 */

/**
 * 有序数组的平方
 */
public class SortedSquare {

    public static void main(String[] args) {
        int[] nums = {-4,-1,0,3,10};
        System.out.println(Arrays.toString(sortedSquare(nums)));
    }

    private static int[] sortedSquare(int[] nums){
        for (int i = 0; i < nums.length; i++) {
            nums[i] = nums[i] * nums[i];
        }
        Arrays.sort(nums);
        return nums;
    }

}
